﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace ESC.Designer.Resources
{
    public class MyCellStyleSelector : StyleSelector
    {
        public override System.Windows.Style SelectStyle(object item, System.Windows.DependencyObject container)
        {
            //decimal? d = 0;
            //foreach (var fieldItem in (IDictionary<String, Object>)item)
            //{
            //    //var v = (fieldItem.Key + ": " + fieldItem.Value);
            //    if (fieldItem.Key == str)
            //    {
            //        d = Convert.ToDecimal(fieldItem.Value);
            //    }
            //}
            object o;
            ((IDictionary<String, Object>)item).TryGetValue(str, out o);
            object o1;
            ((IDictionary<String, Object>)item).TryGetValue("產品代碼(尺寸)", out o1);

            if (o != null && o.ToString() != "" && o1.ToString() != "小計")
            {
                return ActiveStyle;
            }

            return DefaultStyle;
        }
        public string str { get; set; }

        public Style ActiveStyle { get; set; }

        public Style DefaultStyle { get; set; }
    }
}
